home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The X-Philes (2nd Revision)
/
The X-Philes Number 1 (1995).iso
/
xphiles
/
hp48_1
/
data-plo
< prev
next >
Wrap
Internet Message Format
|
1995-03-31
|
3KB
From comp.sys.handhelds Thu Feb 7 11:03:00 1991
Path: mentor.cc.purdue.edu!purdue!news.cs.indiana.edu!samsung!spool.mu.edu!sdd.hp.com!hplabs!hpfcso!rrd
From: rrd@hpfcso.HP.COM (Ray Depew)
Newsgroups: comp.sys.handhelds
Subject: Re: Plotting data point on HP48
Message-ID: <7360065@hpfcso.HP.COM>
Date: 5 Feb 91 17:51:46 GMT
References: <4941@umbc3.UMBC.EDU>
Organization: Hewlett-Packard, Fort Collins, CO, USA
Lines: 65
Rouben Rostamian asks:
>How does one plot the graph of a function given in a tabular form?
>Specifically, I have a program that generates a sequence of (x,y)
>pairs and stores them in the stack. The pairs represent points
>on the graph of the solution of a differential equation.
>Does anyone have a utility program for plotting a graph passing
>through these points? A simple linear interpolation between the points
>will suffice.
Here's a quick program that will do what you want. As with most
connect-the- dots scatter plots, the data points are connected in the
same order they appear in your array. This means that your output may
be ugly and disordered, unless you sort your array first.
I'm reading this from my 48 display and typing it in here, so pleaswe]
firgove typos. You may be able to improve on this code, since I put
it together in only a few minutes.
Regards
Ray Depew
HP ICBD -- IC's by Bill and Dave
rrd@hpfitst1.hp.com
TREND
-----
Draws a SCATTER plot and connects the dots.
Input: Level 1: A real array, or the name of a real array.
Output: Nothing on the stack. (Draws the plot and displays it.)
Caution: Use [STAT] {XCOL} and [STAT] {YCOL} to choose your x- and
y-data columns correctly.
Checksum: #37143d
Bytes: 253.5
Instructions: Use TREND instead of SCATRPLOT -- that is, use it the same way
you would use SCATRPLOT. This means that you have to choose XCOL and YCOL
before you start. If you want to "pretty up" your plot, you can use LABEL,
AXES, DRAX and the other plotting functions to do so.
(In this listing, \GS is Sigma, or "Greek S". Use [VARS] {\GSDAT}.
\-> is "right arrow". Use [Rshift][0],
or [PRG]{OBJ}{\->LIST},
or [PRG]{OBJ}[NXT]{R\->C}.
\=/ is "not equals". Use [PRG]{TEST}[NXT]{\=/}.
)
\<< SCATRPLOT @ To set plot limits and draw axes.
IF DUP TYPE 3 \=/ THEN RCL END @ Get the array on the stack.
DUP SIZE 1 GET @ Array length (number of rows).
\GSPAR DUP 1 GET @ x-data column no.
SWAP 2 GET @ y-data column no.
\-> arry n xcol ycol
\<< 1 n 1 - FOR j @ Number of line segments to draw.
arry DUP j xcol 2 \->LIST GET
OVER j ycol 2 \->LIST GET R\->C @ First endpoint.
OVER j 1 + xcol 2 \->LIST GET
3 PICK j 1 + ycol 2 \->LIST GET R\->C @ The other endpoint.
LINE @ Draw the line.
NEXT
{ } PVIEW @ Keep it in the display for as long
\>> @ as you want it.
\>>